<!-- 下拉选择器 -->
<template>
  <el-select v-model="valueModal" v-bind="$attrs" @change="onChange">
    <el-option
      v-for="item in columns"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    />
  </el-select>
</template>

<script>
export default {
  name: 'YxhySelect',
  props: {
    value: {
      type: [Number, String],
      default: ''
    },
    columns: {
      type: Array,
      default: () => [{ value: 1, label: '默认值' }]
    }
  },
  data() {
    return {
      valueModal: ''
    }
  },
  watch: {
    value: {
      handler(val) {
        this.valueModal = val
      },
      immediate: true
    }
  },
  methods: {
    onChange(e) {
      this.$emit('onChange', e)
      this.$emit('update:value', e)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
